package com.cskaoyan.shopping.wuwencontroller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.shopping.dto.HomeCategoryDto;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.service.impl.CateGoryServiceImpl;
import com.cskaoyan.shopping.service.impl.HomePageServiceImpl;
import com.cskaoyan.shopping.service.impl.NavigationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wuwen
 * @since 2022/10/25
 * 17:01
 */
@RestController
public class ShoppingController {
    @Autowired
    CateGoryServiceImpl cateGoryService;
    @Autowired
    NavigationServiceImpl navigationService;
    @Autowired
    HomePageServiceImpl homePageService;
    @GetMapping("/shopping/categories")
    public ResponseData getCategory(){
        List<HomeCategoryDto> search = cateGoryService.search();
        return new ResponseUtil().setData(search);
    }
    @GetMapping("/shopping/navigation")
    public ResponseData getNavigation(){
        //注意，pannelId等于0。
        List<PanelContentDto> search = navigationService.search();
        return new ResponseUtil().setData(search);
    }
    @GetMapping("/shopping/homepage")
    public ResponseData getHomepage(){
        List<PanelDto> panelDtos = homePageService.searchPanelInfo();
        return new ResponseUtil().setData(panelDtos);
    }
}

